// var o;
// exports.PayData = void 0;
// var $storageClass = require("../../resources/scripts/AL_Framework_Storage_Class");
// var AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");
// var l = {
//     freeRecieved: !1,
//     giftpackRecieveTime: -1,
//     noAdsData: {
//         bool: !1,
//         time: 0
//     },
//     vipData: {
//         bool: !1,
//         time: 0
//     }
// };
// var u = (function (e) {
//     function t() {
//         return (null !== e && e.apply(this, arguments)) || this;
//     }
//     __extends(t, e);
//     t.getInstance = function () {
//         return AL_APP_SDK_MANAGER.localManager.huoqu_cunchu_lei(t);
//     };
//     t.prototype.zhixing_chushihua_chuli = function () {
//         this.chushihua_cunchu_shuju(l);
//         this.chushihua_yuancheng_key(Object.keys(l));
//     };
//     t.prototype.jiancha_zhifu_shuju = function () {
//         this.jiancha_shifou_wu_guanggao();
//         this.jiancha_shifou_vip();
//     };
//     t.prototype.jiancha_shifou_wu_guanggao = function () {
//         var e = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//         if (
//             this.noAdsData.bool &&
//             this.huoqu_riqi_xiaoshi_jiangeshijian(this.noAdsData.time, e) > AL_GAME_HUA_GameConst.GameConst.getInstance().noads_time
//         ) {
//             this.noAdsData.bool = !1;
//             this.noAdsData.time = 0;
//             this.shezhi_cunchu_shuju("noAdsData", this.noAdsData);
//             AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_NOADS_CHANGE);
//         }
//     };
//     t.prototype.jiancha_shifou_vip = function () {
//         var e = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//         if (
//             this.vipData.bool &&
//             this.huoqu_riqi_xiaoshi_jiangeshijian(this.vipData.time, e) > AL_GAME_HUA_GameConst.GameConst.getInstance().vip_time
//         ) {
//             this.vipData.bool = !1;
//             this.vipData.time = 0;
//             this.shezhi_cunchu_shuju("vipData", this.vipData);
//             AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_VIP_CHANGE);
//         }
//     };
//     t.prototype.shuaxin_riqi_xianguan_shuju = function () {
//         this.freeRecieved = !1;
//     };
//     t.prototype.yichu_guanggao = function () {
//         this.noAdsData.bool = !0;
//         this.noAdsData.time = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//         ailin_sdk_manager.yincangBannerGuanggao();
//         this.shezhi_cunchu_shuju("noAdsData", this.noAdsData);
//         AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_NOADS_CHANGE);
//     };
//     t.prototype.huoqu_vip = function () {
//         this.vipData.bool = !0;
//         this.vipData.time = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//         this.shezhi_cunchu_shuju("vipData", this.vipData);
//         AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_VIP_CHANGE);
//     };
//     t.prototype.huoqu_shifou_yichu_guanggao = function () {
//         this.jiancha_shifou_wu_guanggao();
//         return this.noAdsData.bool;
//     };
//     t.prototype.huoqu_shifou_vip = function () {
//         this.jiancha_shifou_vip();
//         return this.vipData.bool;
//     };
//     t.prototype.huoqu_vip_shengyu_shijian = function () {
//         if (this.huoqu_shifou_vip()) {
//             var e = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//             var t = this.huoqu_riqi_xiaoshi_jiangeshijian(this.vipData.time, e);
//             return AL_GAME_HUA_GameConst.GameConst.getInstance().vip_time - t;
//         }
//         return 0;
//     };
//     t.prototype.huoqu_wu_guanggao_shengyu_shijian = function () {
//         if (this.huoqu_shifou_yichu_guanggao()) {
//             var e = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//             var t = this.huoqu_riqi_xiaoshi_jiangeshijian(this.noAdsData.time, e);
//             return AL_GAME_HUA_GameConst.GameConst.getInstance().noads_time - t;
//         }
//         return 0;
//     };
//     t.prototype.get_Gift_Pack_Recieved = function () {
//         return -1 != this.giftpackRecieveTime;
//     };
//     t.prototype.set_Gift_Pack_Recieved = function () {
//         this.giftpackRecieveTime = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//     };
//     t.prototype.huoqu_libao_shengyu_shijian = function () {
//         if (-1 == this.giftpackRecieveTime) {
//             return 0;
//         }
//         var e = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian() - this.giftpackRecieveTime;
//         var t = 36e5 * AL_GAME_HUA_GameConst.GameConst.getInstance().giftpack_cd;
//         return e > t || e < 0
//             ? ((this.giftpackRecieveTime = -1), this.shezhi_cunchu_shuju("giftpackRecieveTime", this.giftpackRecieveTime), 0)
//             : t - e;
//     };
//     t.prototype.huoqu_riqi_xiaoshi_jiangeshijian = function (e, t) {
//         var n = new Date(e).getTime();
//         return (new Date(t).getTime() - n) / 1e3 / 60 / 60;
//     };
//     t.bundle = AL_GAME_HUA_Define.Define.GAME_NAME;
//     t.key = "_pay";
//     return t;
// })($storageClass.AL_Framework_Storage_Class);
// exports.PayData = u;


/** 
 * PayData class manages payment-related data and operations.
 */
var o;
exports.PayData = void 0;

// Import the necessary modules
const $storageClass = require("../../resources/scripts/AL_Framework_Storage_Class");
const AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
const AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
const AL_GAME_HUA_GameConst = require("./AL_GAME_HUA_GameConst");

// Initial storage data configuration
const initialStorageData = {
    freeReceived: false,
    giftpackReceiveTime: -1,
    noAdsData: {
        isActive: false,
        timestamp: 0
    },
    vipData: {
        isActive: false,
        timestamp: 0
    }
};

class PayData extends $storageClass.AL_Framework_Storage_Class {
    static bundle = AL_GAME_HUA_Define.Define.GAME_NAME;
    static key = "_pay";

    constructor() {
        super();
    }

    /**
     * Get the singleton instance of PayData.
     * @returns {PayData} Singleton instance.
     */
    static getInstance() {
        return AL_APP_SDK_MANAGER.localManager.huoqu_cunchu_lei(PayData);
    }

    /**
     * Initialization method for setting up storage and remote keys.
     */
    zhixing_chushihua_chuli() {
        this.chushihua_cunchu_shuju(initialStorageData);
        this.chushihua_yuancheng_key(Object.keys(initialStorageData));
    }

    /**
     * Check all payment-related data.
     */
    jiancha_zhifu_shuju() {
        this.jiancha_shifou_wu_guanggao();
        this.jiancha_shifou_vip();
    }

    /**
     * Validate no ads data and update if the duration has expired.
     */
    jiancha_shifou_wu_guanggao() {
        const currentTime = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
        if (this.noAdsData.isActive && this.huoqu_riqi_xiaoshi_jiangeshijian(this.noAdsData.timestamp, currentTime) > AL_GAME_HUA_GameConst.GameConst.getInstance().noads_time) {
            this.noAdsData.isActive = false;
            this.noAdsData.timestamp = 0;
            this.shezhi_cunchu_shuju("noAdsData", this.noAdsData);
            AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_NOADS_CHANGE);
        }
    }

    /**
     * Validate VIP data and update if the duration has expired.
     */
    jiancha_shifou_vip() {
        const currentTime = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
        if (this.vipData.isActive && this.huoqu_riqi_xiaoshi_jiangeshijian(this.vipData.timestamp, currentTime) > AL_GAME_HUA_GameConst.GameConst.getInstance().vip_time) {
            this.vipData.isActive = false;
            this.vipData.timestamp = 0;
            this.shezhi_cunchu_shuju("vipData", this.vipData);
            AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_VIP_CHANGE);
        }
    }

    /**
     * Refresh daily data such as free receipts.
     */
    shuaxin_riqi_xianguan_shuju() {
        this.freeReceived = false;
    }

    /**
     * Remove ads by setting noAdsData status to active and updating the timestamp.
     */
    yichu_guanggao() {
        this.noAdsData.isActive = true;
        this.noAdsData.timestamp = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
        ailin_sdk_manager.yincangBannerGuanggao();
        this.shezhi_cunchu_shuju("noAdsData", this.noAdsData);
        AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_NOADS_CHANGE);
    }

    /**
     * Activate VIP status and update the timestamp.
     */
    huoqu_vip() {
        this.vipData.isActive = true;
        this.vipData.timestamp = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
        this.shezhi_cunchu_shuju("vipData", this.vipData);
        AL_APP_SDK_MANAGER.emit(AL_GAME_HUA_Define.GameEvent.ON_VIP_CHANGE);
    }

    /**
     * Check if ads removal is currently active.
     * @returns {boolean} true if ads removal is active, false otherwise.
     */
    huoqu_shifou_yichu_guanggao() {
        this.jiancha_shifou_wu_guanggao();
        return this.noAdsData.isActive;
    }

    /**
     * Check if VIP status is currently active.
     * @returns {boolean} true if VIP is active, false otherwise.
     */
    huoqu_shifou_vip() {
        this.jiancha_shifou_vip();
        return this.vipData.isActive;
    }

    /**
     * Get remaining VIP duration in hours.
     * @returns {number} Hours remaining for VIP status.
     */
    huoqu_vip_shengyu_shijian() {
        if (this.huoqu_shifou_vip()) {
            const currentTime = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
            const elapsedHours = this.huoqu_riqi_xiaoshi_jiangeshijian(this.vipData.timestamp, currentTime);
            return AL_GAME_HUA_GameConst.GameConst.getInstance().vip_time - elapsedHours;
        }
        return 0;
    }

    /**
     * Get remaining no ads duration in hours.
     * @returns {number} Hours remaining for no ads status.
     */
    huoqu_wu_guanggao_shengyu_shijian() {
        if (this.huoqu_shifou_yichu_guanggao()) {
            const currentTime = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
            const elapsedHours = this.huoqu_riqi_xiaoshi_jiangeshijian(this.noAdsData.timestamp, currentTime);
            return AL_GAME_HUA_GameConst.GameConst.getInstance().noads_time - elapsedHours;
        }
        return 0;
    }

    /**
     * Check if a gift pack has been received.
     * @returns {boolean} true if a gift pack has been received, false otherwise.
     */
    huoqu_libao_shifou_yilingqu() {
        return this.giftpackReceiveTime !== -1;
    }

    /**
     * Set the gift pack received timestamp to current time.
     */
    shezhi_libao_shifou_yilingqu() {
        this.giftpackReceiveTime = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
    }

    /**
     * Get the remaining time until a new gift pack can be received.
     * @returns {number} Remaining time in milliseconds.
     */
    huoqu_libao_shengyu_shijian() {
        if (this.giftpackReceiveTime === -1) {
            return 0;
        }
        const elapsedTime = AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian() - this.giftpackReceiveTime;
        const cooldownTime = 36e5 * AL_GAME_HUA_GameConst.GameConst.getInstance().giftpack_cd;
        if (elapsedTime > cooldownTime || elapsedTime < 0) {
            this.giftpackReceiveTime = -1;
            this.shezhi_cunchu_shuju("giftpackReceiveTime", this.giftpackReceiveTime);
            return 0;
        }
        return cooldownTime - elapsedTime;
    }

    /**
     * Calculate the duration in hours between two timestamps.
     * @param {number} startTime - Start timestamp in milliseconds.
     * @param {number} endTime - End timestamp in milliseconds.
     * @returns {number} Duration in hours.
     */
    huoqu_riqi_xiaoshi_jiangeshijian(startTime, endTime) {
        const startTimestamp = new Date(startTime).getTime();
        return (new Date(endTime).getTime() - startTimestamp) / 3600000;
    }
}

exports.PayData = PayData;